import java.sql.Connection;
import java.sql.PreparedStatement;

public class Update {
    //进行增删改操作
    public static void update(String sql, Object ...arg){
        Connection conn = null;
        PreparedStatement ps = null;
        try {
            //获取数据库连接
            conn = utils.getConnection();
            //预编译sql语句
            ps = conn.prepareStatement(sql);
            //填充占位符
            for (int i = 0; i < arg.length; i++) {
                ps.setObject(i + 1, arg[i]);
            }
            //执行sql语句
            ps.execute();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            //关闭资源
            utils.closeResource(conn,ps);
        }
    }

    public static void main(String[] args) {
        String sql = "update user set UserMarkers = '教师' where UserName = ?";

        Update.update(sql, "张三");
    }
}
